package com.neueedu.android;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;


public class MyFragment extends Fragment   implements AdapterView.OnItemClickListener {


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,   Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View myFragment = inflater.inflate(R.layout.fragment_my, container, false);

        return myFragment;
    }


    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);

        //查找ListView
        ListView lv = getActivity().findViewById(R.id.lv);

        //创建适配器

        String[] data = new String[]{"我的联系人", "我的账户", "我的密码","加载动态图片","WebView1-Net","WebView1-Local"};
        ArrayAdapter arrayAdapter = new ArrayAdapter(getActivity(), android.R.layout.simple_list_item_1,data);



        //绑定数据
        lv.setAdapter(arrayAdapter);

        //点击ListView的点击事件
        lv.setOnItemClickListener(this);

    }

    @Override
    public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
        Class targetClass = null;
        switch (position){
            case  0:
                targetClass = ConcatActivity.class;
                break;
            case  1:
                targetClass = MyAccountActivity.class;
                break;
            case  2:
                targetClass = PasswordActivity.class;
                break;
            case  3:
                targetClass = ImageViewActivity.class;
                break;
            case  4:
                targetClass = WebViewNetActivity.class;
                break;
            case  5:
                targetClass = WebViewLocalActivity.class;
                break;
        }

        Intent intent = new Intent(getActivity(),targetClass);
        startActivity(intent);
    }

}
